﻿using System;
using System.Windows;
using System.Windows.Controls;
using ClimateControl.Client;
using ClimateControl.Client.ViewModel;

namespace ClimateControl.Client.View
{
    /// <summary>
    /// Interaction logic for MainView.xaml
    /// </summary>
    public partial class MainView : Window
    {
        public MainView()
        {
            InitializeComponent();
            DataContext = new MainViewModel();
            if (DataContext is IDisposable)
                Closed += (sender, e) => ((IDisposable)DataContext).Dispose();
            Loaded += (sender, e) => SetGlowVisibility(prog, Visibility.Hidden);
        }

        private void Image_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            new SettingsView(this).ShowDialog();
        }

        private void SetGlowVisibility(ProgressBar progressBar, Visibility visibility)
        {
            var glow = progressBar.Template.FindName("PART_GlowRect", progressBar) as UIElement;
            if (glow != null) glow.Visibility = visibility;
        }
    }
}
